package com.dcm.seckill.mapper;

import com.dcm.seckill.entity.SeckillShopEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author 牛浩
 */
@Component
public interface SeckillShopMapper {
    /**
     * 查询
     * @return
     */
    List<SeckillShopEntity> findAll();

    /**
     * 添加方法
     * @param seckillShop
     */
    void add(@RequestBody SeckillShopEntity seckillShop);

    /**
     * 模糊查询
     * @param state
     * @param configure
     * @param id
     * @return
     */
    List<SeckillShopEntity> search(@Param("state") Integer state,@Param("configure") String configure,@Param("id") Long id);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    SeckillShopEntity findOne(Long id);

    /**
     * 根据姓名查询
     * @param name
     * @return
     */
    SeckillShopEntity findByName(String name);

    /**
     * 根据id更新库存
     * @param id
     * @param limitedSurplus
     */
    void reduce(@Param("id") Long id,@Param("limitedSurplus") Integer limitedSurplus);

    /**
     * 根据id减库存
     * @param id
     * @return
     */
    int decrNumberById(Long id);
}
